<#include "./template.ftl">

<#macro head>
<title>移动营销第一平台-Morketing</title>
<link rel="stylesheet" href="${base}/client/css/list.css">
<link rel="stylesheet" href="${base}/client/css/dakaList.css">
<link rel="stylesheet" href="${base}/client/css/productList.css">
<link rel="stylesheet" href="${base}/client/css/gongsiList.css">
<link rel="stylesheet" href="${base}/client/css/baike.css">
<link rel="stylesheet" href="${base}/client/css/wenda.css">
<link rel="stylesheet" href="${base}/client/css/moke.css">
<link rel="stylesheet" href="${base}/client/css/search.css">
<style>
    .highlight { background-color: yellow }
</style>
</#macro>
<#macro content>
<div id="contents">

    <div class="main wrap clearfix">
        <div class="main-left f-l clearfix">
            <div class="index-tab">
                <div class="news-item show">
                    <!--大咖开始-->
                    <#if peoples??>
                        <h2 class="common-h2">大咖</h2>
                         <div class="dk-lists">
                            <ul class="clearfix">
                                <#list peoples as people>
                                    <li>
                                        <a href="${base}/people/id/${people.id}"style="display: inline-block;width: inherit;height: inherit">
                                            <div style="height:100%;width:160%;margin-left: -30%;text-align: center">
                                                <img style="height:100%;width:auto" src="${base}/system/getImg?imgId=${people.iconUrl}&w=384"alt="">
                                            </div>
                                            <div class="cell">
                                            <h2 class="highlight-item">${people.name}</h2>
                                            <p>${people.position}</p>
                                        </div>
                                        </a>
                                    </li>
                                </#list>
                            </ul>
                        </div>
                    </#if>
                    <!--大咖结束-->

                    <!--产品开始-->
                    <#if products??>
                        <h2 class="common-h2">产品</h2>
                        <div class="pl-lists">
                        <#list products as product>
                            <div class="li-item">
                                <div class="l f-l">
                                    <a href="${base}/product/id/${product.id}" style="display: inline-block;width: inherit;height: inherit">
                                        <div style="height:100%;width:160%;margin-left: -30%;text-align: center">
                                            <img style="height:100%;width:auto" src="${base}/system/getImg?imgId=${product.iconUrl!''}&w=110&h=110" alt="">
                                        </div>
                                    </a>
                                </div>
                                <div class="cell f-l">
                                    <a href="${base}/product/id/${product.id}"><h2 class="highlight-item">${product.name}</h2></a>
                                    <p>阶段:<span>${product.process}</span></p>
                                    <p>平台:<span>${product.platformStr}</span></p>
                                    <p>所属类型:<span>${product.typeStr}</span></p>
                                    <p>合作方式: <span>${product.cooperationWays}</span></p>
                                </div>
                            </div>
                        </#list>
                        </div>
                    </#if>
                    
                    <!--产品结束-->

                    <!--公司开始-->
                    <#if companys??>
                        <h2 class="common-h2">公司</h2>
                        <div class="gs-lists">
                        <#list companys as company>
                            <li>
                                <div class="pic f-l">
                                    <a href="${base}/company/id/${company.id}"style="display: inline-block;width: inherit;height: inherit">
                                        <div style="height:100%;width:100%;">
                                            <img style="height:100%;width:auto" src="${base}/system/getImg?imgId=${company.iconUrl}&w=208&h=208" alt="">
                                        </div>
                                    </a>
                                </div>
                                <div class="cell f-l">
                                    <a href="${base}/company/id/${company.id}"><h2 class="highlight-item">${company.name}</h2></a>
                                    <p>主营业务:<span>${company.majorBiz}</span></p>
                                    <p>涉及领域:<span>${company.zone}</span></p>
                                    <p>工作地区:<span>${company.area}</span></p>
                                    <p>公司规模:<span>${company.scale}人以上</span></p>
                                    <p>公司网址:<span>${company.website}</span></p>
                                </div>
                            </li>
                        </#list>
                        </div>
                    </#if>
                    <!--公司结束-->

                    <!--百科开始-->
                    <#if bakes??>
                        <h2 class="common-h2">百科</h2>
                        <#list bakes as bake>
                            <div class="li-item">
                                <div class="f-l l"><a href="${base}/baike/${bake.id}"><img width="100%" src="${base}/system/getImg?imgId=${bake.imgUrl}&w=224&h=168" alt="${bake.title}"></a></div>
                                <div class="cell">
                                    <h2><a href="${base}/baike/${bake.id}" class="highlight-item">${bake.title}</a></h2>
                                    <p>${bake.content!""}
                                    </p>
                                    <div class="tips">
                                        <div class="from">
                                            <span class="time">来自: ${bake.source}
                                                <#--|  发布日期：${bake.createTimeStr}-->
                                            </span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </#list>
                    </#if>
                    <!--百科结束-->

                    <!--问答开始-->

                    <#if ups??>
                        <h2 class="common-h2">问答</h2>
                        <div class="wenda-lists">
                        <#list ups as up>
                            <div class="wd-list">
                                <h3><a href="${base}/question/detail/${up.id}" class="highlight-item">${up.title}</a></h3>
                                <p class="p">${up.content}</p>
                                <div class="tips"><span>${up.createTimeStr}</span> <span>提问者：${up.creatorStr}</span></div>
                                <div class="total">${up.num}个回答</div>
                            </div>
                        </#list>
                        </div>
                    </#if>
                    <!--问答结束-->

                    <!--魔客专栏文章开始-->
                    <#if articles??>
                        <h2 class="common-h2">魔客专栏</h2>
                        <div class="moke-list">
                        <#list articles as article>
                            <div class="li-item">
                                <div class="f-l l">
                                    <a href="${base}/moke/posts/${article.id}"style="display: inline-block;width: inherit;height: inherit">
                                        <div style="height:100%;width:160%;margin-left: -30%;text-align: center">
                                            <img style="height:100%;width:auto" src="${base}/system/getImg?imgId=${article.postImg!''}&w=224&h=168" alt="">
                                        </div>
                                    </a>
                                </div>
                                <div class="cell">
                                    <h2><a href="${base}/moke/posts/${article.id}" class="highlight-item">${article.postTitle}</a></h2>
                                    <p class="highlight-item">${article.postContent!''}</p>
                                    <div class="tips">
                                        <div class="from">
                                            <a href="${base}/moke/user/${article.postAuthor}">
                                                <span class="name"><img width="100%" src="${base}/system/getImg?imgId=${article.authorPhoto!''}&w=48&h=48" alt="">${article.postAuthorStr!''}</span>
                                            </a>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </#list>
                        </div>
                    </#if>
                    <!--魔客专栏文章结束-->
                    <!--资讯文章 Start-->
                    <div id="post_title">
                        <h2 class="common-h2">资讯文章</h2>
                    </div>
                    <div id="general_post">

                    </div>
                    <!--资讯文章 End-->
                </div>
            </div>
        </div>


        <div class="main-right f-r clearfix">
            <#include "widget/ad.ftl"/>
            <#include "widget/hot_posts.ftl"/>
        </div>

    </div>
</div>
</#macro>
<#macro js>
<#--<script src="${base}/client/js/list.js"></script>-->
<script type="text/javascript" src="${base}/client/js/jquery.highlight-5.closure.js"></script>
<script type="text/javascript">
    $('.highlight-item').highlight('${keywords!''}');

    $(function(){
        var contentsTpl = '' +
                '{{each data.list as v i}}' +
                '<div class="li-item">' +
                '{{if v.postTerm==172 }}'+
                '       <div class="rel rel0">{{v.postTermsStr}}</div>'+

                '{{else if v.postTerm== 171}}'+
                '       <div class="rel rel4">{{v.postTermsStr}}</div>'+

                '{{else if v.postTerm== 169}}'+
                '       <div class="rel rel2">{{v.postTermsStr}}</div>'+

                '{{else if v.postTerm== 162}}'+
                '       <div class="rel rel3">{{v.postTermsStr}}</div>'+

                '{{else}}'+
                '       <div class="rel rel1">{{v.postTermsStr}}</div>'+
                '{{/if}}'+

                '<div class="f-l l">' +
                    '<a href="${base}/posts/{{v.id}}" style="display: inline-block;width: inherit;height: inherit">'+
                        '<div style="height:100%;width:160%;margin-left: -30%;text-align: center">'+
                            '<img style="height:100%;width:auto" src="${base}/system/getImg?imgId={{v.postImg}}&h=168&w=224">'+
                        '</div>'+
                    '</a>' +
                '</div>' +
                '<div class="cell">' +
                '   <h2><a href="${base}/posts/{{v.id}}">{{v.postTitle}}</a></h2>' +
                '   <p>{{#v.postContent}}</p>' +
                '   <div class="tips">' +
                '       <div class="from">' +
                '           <span class="time">来自:<a href="${base}/profile?userId={{v.postAuthor}}">{{v.postAuthorStr}}</a> | {{v.createTimeStr}}</span>' +
                '           <span class="view">{{v.view}}</span>' +
                '       </div>' +
                '       <div class="share">分享至：' +
                '           <span class="social-share" data-initialized="true">' +
                '               <a href="${base}/posts/{{v.id}}" class="social-share-icon icon-weibo"></a>' +
                '               <a href="${base}/posts/{{v.id}}" class="social-share-icon icon-wechat"></a>' +
                '           </span>' +
                '       </div>' +
                '   </div>' +
                '</div>' +
                '</div>' +
                '{{/each}}';

        function pageClickEvent (page){
            var ajax_data = {
                keywords: '${keywords!''}',
                posts_per_page: 10,
                page:page
            };
            $.ajax({
                url: '${base}/search/post/page',
                type: 'GET',
                dataType: 'json',
                data:ajax_data,
                success:function(res){
                    if(res.status == 1){
                        if(res.data == null || res.data.total <= 0){
                            $("#post_title").html("");
                            return;
                        }
                        var html = template.render(contentsTpl)(res);
                        $('#general_post').html(html);
                        $('#general_post').append('<div class="index-page"></div>');
                        var Page = new Pagination(
                                $('#general_post'),
                                {
                                    totalNums: res.data.total || 0,//数据总条数，必填
                                    pageSize: 10,//每页显示条数
                                    currentPage: page,//当前页码
                                    pageClickCallBack:pageClickEvent
                                }
                        )
                    }else{
                        console.log('出错了')
                    }
                }
            })
        }

        pageClickEvent (1);
    });
</script>
</#macro>